
/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package Apusic.impl;

import Apusic.ApusicPackage;
import Apusic.DataSource;
import Apusic.DataSourceManager;

import java.util.Collection;
import java.util.Collection;
import java.util.Collection;
import java.util.Collection;
import java.util.Collection;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.EObjectImpl;
import org.eclipse.emf.ecore.util.EObjectResolvingEList;
import javax.management.ObjectName;
import org.eclipse.emf.ecore.EObject;
import com.apusic.admin.config.*;
import com.apusic.admin.*;

import cn.edu.pku.sei.ra.wrapping.CommonWrapping.WrappingEObject;
import cn.edu.pku.sei.ra.wrapping.CommonWrapping.impl.WrappingEObjectImpl;
import cn.edu.pku.sei.ra.wrapping.CommonWrapping.util.EObjectContainmentEListForWrapping;
import cn.edu.pku.sei.ra.wrapping.CommonWrapping.util.EObjectResolvingEListForWrapping;
import cn.edu.pku.sei.ra.wrapping.CommonWrapping.util.ImagePool;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Data Source Manager</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link Apusic.impl.DataSourceManagerImpl#getDataSources <em>Data Sources</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class DataSourceManagerImpl extends WrappingEObjectImpl implements DataSourceManager
{
  /**
   * The cached value of the '{@link #getDataSources() <em>Data Sources</em>}' reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDataSources()
   * @generated
   * @ordered
   */
  protected EList<DataSource> dataSources;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected DataSourceManagerImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return ApusicPackage.Literals.DATA_SOURCE_MANAGER;
  }

  
  

  
  
  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */ 
   public boolean isForCore(Object arg0){
   	boolean result=true;
   	if(core==null) return false;
    try{
    result=true;
    }
    catch(Exception e){
      result=false;
    }
    return result;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */ 
  public List listSubCores(int featureID){
    List result=new ArrayList();
  
    DataSourceMgr core=(DataSourceMgr)this.getCore();
    if(core==null) 
      return result;
    switch(featureID){
    
    case ApusicPackage.DATA_SOURCE_MANAGER__DATA_SOURCES:
  
      try {
  List<ObjectName> dsNames = core.listDataSource();
            for(int i=0;i<dsNames.size();i++)
            {
            	result.add(core.fetchDataSource(dsNames.get(i).getKeyProperty("name")));
            }
  } catch (Exception e) {
    e.printStackTrace();
  }
    break;
    
  }
    return result;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */ 
  public EClass getChildClassMap(Object object){
    ApusicPackage pack=ApusicPackage.eINSTANCE;	
  
    return null;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<DataSource> getDataSources()
  {

    
    if (dataSources == null)
    {
  
  
    
      
      dataSources = new EObjectResolvingEListForWrapping<DataSource>(
          DataSource.class, 
          this, 
          ApusicPackage.DATA_SOURCE_MANAGER__DATA_SOURCES,
          ApusicPackage.eINSTANCE.getDataSource()
        );
        
  }
  
      ((EObjectResolvingEListForWrapping<DataSource>)dataSources)
      .refreshWrap();
  
    return dataSources;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case ApusicPackage.DATA_SOURCE_MANAGER__DATA_SOURCES:
        return getDataSources();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case ApusicPackage.DATA_SOURCE_MANAGER__DATA_SOURCES:
        getDataSources().clear();
        getDataSources().addAll((Collection<? extends DataSource>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case ApusicPackage.DATA_SOURCE_MANAGER__DATA_SOURCES:
        getDataSources().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case ApusicPackage.DATA_SOURCE_MANAGER__DATA_SOURCES:
        return dataSources != null && !dataSources.isEmpty();
    }
    return super.eIsSet(featureID);
  }

} //DataSourceManagerImpl
